<?php

/**
 *
 */
class Sx_bind extends CI_Controller {
	//用户ID
	private $userID;
	//绑定平台名称
	private $bindSys;
	//用户认证KEY
	private $postMobiKey;
	//用户sessionID
	private $postSessionId;
	//操作类型：绑定0，取消绑定为1
	private $bindAction;
	private $userArr;

	public function index() {
		
		$this->bindSys = $this -> input -> post("bindsys");
		$this -> postMobiKey = $this -> input -> post('mobikey');
		$this -> postSessionId = $this -> input -> post('sessionid');
		$this -> bindAction = $this -> input -> post('action');		
		$this -> userArr = $this -> sx_useropen_mod -> user_con($this -> postMobiKey, $this -> postSessionId, TRUE);
		if (!$this -> userArr) {			
			print($this -> fengchaoclass -> showhckmsg("-1", NULL, $this -> lang -> line('hck_friend_out'), TRUE));
			exit ;
		}
		$this -> userID = $this -> userArr['userid'];
		
		switch ($this -> bindAction) {
			case '0':
				$this->set_bind( $this -> userID, $this->bindSys);
				break;
			case '1':
				
				break;
			
			default:
				print($this -> fengchaoclass -> showhckmsg("1", NULL, $this -> lang -> line('hck_err'), TRUE));
				break;
		}
	}
	// ----------------------------------------------------------------
	/*
	 * 绑定外部帐号set_bind
	 * @access	private
	 * @param	$id  用户ID 	string
	 * @param	$b  绑定的内容 	string
	 * @return	json/array
	 */
	// ----------------------------------------------------------------
private function set_bind($id,$b){
		if(func_num_args()<2){
			print($this -> fengchaoclass -> showhckmsg("1", NULL, $this -> lang -> line('hck_parame'), TRUE));
		}
	if($this->sx_db_mod->set_bind($id,$b)){
		print($this -> fengchaoclass -> showhckmsg("0", NULL, $this -> lang -> line('hck_bind_Y'), TRUE));
	}else{
			print($this -> fengchaoclass -> showhckmsg("0", NULL, $this -> lang -> line('hck_bind_N'), TRUE));
		}
		
	}

}
?>